home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / rmtc01.zip / READDEF.C < prev    next >
Text File  |  1991-11-02  |  1KB  |  52 lines

  1. /* ************************************************ */
  2. /*                     WriteDef.c                   */
  3. /* Purpose : Reads a DEF file                      */
  4. /* Compiler: Turbo C V2.0                           */
  5. /* Date    : Oct 31, 1991                           */
  6. /* ************************************************ */
  7.  
  8. #include <graphics.h>
  9. #include <stdio.h>
  10.  
  11. main()
  12. {
  13.   FILE *F;
  14.   int driver, mode, size;
  15.   int x, y, i, j, xoffset, yoffset;
  16.   int col, ch;
  17.   driver=EGA;
  18.   mode=EGAHI;
  19.   initgraph(&driver,&mode,"");      /* Set path to your EGAVGA.BGI   */
  20.   x=300;
  21.   y=120;
  22.   xoffset=0;
  23.   yoffset=0;
  24.   F=fopen("Rm.def","r");            /* Rm.def must be in current */
  25.   do                            /* directory.                    */
  26.    {
  27.     ch=fgetc(F);
  28.     if (ch=='\n')
  29.     {
  30.       xoffset=0;
  31.       yoffset++;
  32.     }
  33.     else
  34.       {
  35.     if (ch>47 && ch < 58)
  36.      {
  37.        col=ch-48;
  38.        putpixel(x+xoffset,y+yoffset,col);
  39.      }
  40.     else  if (ch>64 && ch<71)
  41.      {
  42.        col=ch-55;
  43.        putpixel(x+xoffset,y+yoffset,col);
  44.      }
  45.     xoffset++;
  46.      }
  47.    } while (ch!=eof(F));
  48.  
  49.   fclose(F);
  50.   getch();
  51.   closegraph();
  52. }